<!--
* @description:新增油费
* @fileName: TheNewFuel
* @author:李周蓬
* @date:2021-1-
* @后台人员:李周蓬
-->
<template>
  <div>
    <table>
      <tr>
        <td>车牌号：</td>
        <td>
          <el-input
            v-model="AddData.LicenseNumber"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>加油费用/元：</td>
        <td>
          <el-input
            v-model="AddData.ComeCost"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>加油量/L：</td>
        <td>
          <el-input
            v-model="AddData.FuelCharge"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>起始公里数：</td>
        <td>
          <el-input
            v-model="AddData.BeginKM"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <tr>
        <td>支付方式：</td>
        <td>
          <el-select v-model="AddData.PayTypeId" placeholder="请选择">
            <el-option
              v-for="item in bindData"
              :key="item.value"
              :label="item.DictionaryName"
              :value="item.Id"
            >
            </el-option>
          </el-select>
        </td>
      </tr>
      <tr>
        <td>经办人：</td>
        <td>
          <el-input v-model="AddData.Agent" placeholder="请输入内容"></el-input>
        </td>
      </tr>
      <tr>
        <td>备注：</td>
        <td>
          <el-input type="textarea" v-model="AddData.Remark"></el-input>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <el-button type="primary" @click="add">提交</el-button>
          <el-button @click="go">取消</el-button>
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      AddData: {
        OilCostNumber: "",
        LicenseNumber: "",
        ComeCost: "",
        FuelCharge: "",
        BeginKM: "",
        PayTypeId: "",
        Agent: "",
        Remark: "",
      },
      bindData:[],
    };
  },
  methods: {
    bind() {
      this.$axios
        .get("https://localhost:44399/api/app/oil-cost/bind")
        .then((res) => {
          let d = res.data.PageData;
          this.bindData = d.filter((u) => {
            return u.DictionaryType == "youfei_zf";
          });
          console.log(this.bindData);
        });
    },
    add() {
      this.$axios
        .post("https://localhost:44399/api/app/oil-cost/add-oil-cost", this.AddData)
        .then((res) => {
          if (res.data > 0) {
            this.$message({
              type: "success",
              message: "添加成功!",
            });
            this.$router.push("/TheOwnerManagement");
          } else {
            this.$message({
              type: "error",
              message: "添加失败!",
            });
          }
        });
    },
    go() {
      this.$router.go(-1);
    },
  },
  created() {
    this.bind();
  },
};
</script>

<style>
</style>